<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modeling</title>
<?php echo importCSS("template.css|style.css|person.css|person-profile.css|font.css");?>
<?php echo importJS("jquery.min.js|input.js|signup.js");?>
<!-- Plugin -->
<link rel="stylesheet" href="__ROOT__/themes/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="__ROOT__/themes/uploadify/uploadify.css" />
<script type="text/javascript" src="__ROOT__/themes/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$().ready(function () {
	$('#countrybutton').fancybox({
		'margin'	:	0,
		'padding'	:	0,
		'width'	:	500,
	});
	$('#file_upload').uploadify({
        'swf'      : '__ROOT__/themes/uploadify/uploadify.swf',
        'uploader' : '<?php echo U("User/uploadAvatar");?>?swfk=<?php echo ($ukver); ?>',
        'onUploadSuccess' : function(file, data, response) {
        	data = JSON.parse(data);
        	if (data.error) {
        		alert(data.msg);
        	} else {
        		$("._avatar").attr("src","__ROOT__/data/avatars/thumb_"+data.msg);
        	}
        	
        }
	}).uploadify('settings','buttonText','<?php echo L('PERSON_SELECTFILE');?>');
});
</script>
<!-- Plugin -->
</head>
<body>
<?php echo L('LANG_FONT');?>
<script> var THEME_ROOT = '__ROOT__/themes/' ; </script>
<div class="header clearfix">
	<div class="center">
    	<a href="<?php echo U('/index');?>"><div class="logo">
        	<img src="__ROOT__/themes/images/logo.png" />
        </div></a>
        <div class="menu">
        	<a href="<?php echo U('/work/index');?>" <?php echo ($nav_menu=="work"?" class='now'":"");?>><div><?php echo L('HEADER_WORK');?></div></a> <!-- class="now"-->
            <a href="<?php echo U('/contractor/index');?>" <?php echo ($nav_menu=="contractor"?" class='now'":"");?>><div><?php echo L('HEADER_CONTRACTOR');?></div></a>
            <a href="<?php echo U('/space/index');?>" <?php echo ($nav_menu=="space"?" class='now'":"");?>><div><?php echo L('HEADER_MY_SPACE');?></div></a>
        </div>
        <div class="search">
        	<div><img src="__ROOT__/themes/images/search.png" /></div>
        	<form method="get" action="<?php echo U('/work/index');?>" >
            <input type="text" id="search" name="name" value="<?php echo L('HEADER_SEARCH');?>" onfocus="if(value=='<?php echo L('HEADER_SEARCH');?>') {value=''} setStyleOne(this.id)" onblur="if (value=='') { value='<?php echo L('HEADER_SEARCH');?>' } setStyleTwo(this.id)"/>
            </form>
        </div>
        <?php if ($_cUser) { ?>
        <div class="signafter">
        	<a href="<?php echo U('/signout');?>"><div  class="outbutton"><?php echo L('HEADER_SIGN_OUT');?></div></a>
        	<a href="<?php echo U('/space/index');?>"><div class="word"><?php echo ($_cUser["username"]); ?></div></a>
        </div>
        <?php } else { ?>
        <div class="sign">
        	<a href="<?php echo U('/join');?>"><div><?php echo L('HEADER_JOIN');?></div></a>
            <a href="<?php echo U('/signin');?>"><div><?php echo L('HEADER_SIGN_IN');?></div></a>
        </div>
        <?php } ?>
    </div>
</div>
<div class="clear"></div>

<div class="main center clearfix profile">
	<div class="leftbox">
    			<div class="inforbox">
            <div class="pic"><img src="<?php echo getAvatar($_cUser);?>" width=100/></div>
            <div class="left">
            	<div class="name"><?php echo ($_cUser["username"]); ?></div>
                <div class="clear"></div>
                <?php if(($_cUser["isverify"]) == "4"): ?><div class="aut">
                	<img src="__ROOT__/themes/images/vendor-acc.png" style="float:left;"/>
                    <div class="left"><?php echo h(xserialize($_cUser['verifyinfo'],'realname'));?></div>
                </div><?php endif; ?>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
        		<div class="menubox">
        	<div class="titleno"><?php echo L('PERSON_PROJECTS');?></div>
            <a href="<?php echo U('/space/publish');?>"><div class="tab"><?php echo L('PERSON_PUBLISH_A_PROJECT');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/view');?>"><div class="tab"><?php echo L('PERSON_MY_PROJECTS');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/bid');?>"><div class="tab"><?php echo L('PERSON_BIDDING_PROJECTS');?></div></a>
            <div class="clear"></div>
            
            <div class="title"><?php echo L('PERSON_USER_SERVICE');?></div>
            <a href="<?php echo U('/space/profile');?>"><div class="tab"><?php echo L('PERSON_MY_PROFILE');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/case');?>"><div class="tab"><?php echo L('PERSON_MY_CASES');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/favorite');?>"><div class="tab"><?php echo L('PERSON_MY_CONCERNS');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/cer');?>"><div class="tab"><?php echo L('PERSON_REAL_CERTIFICATION');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/password');?>"><div class="tab"><?php echo L('PERSON_CHANGE_PASSWORD');?></div></a>
            <div class="clear"></div>
            
            <div class="title"><?php echo L('PERSON_MY_ACCOUNTS');?></div>
            <a href="<?php echo U('/space/account');?>"><div class="tab"><?php echo L('PERSON_ACCOUNT_INFO');?></div></a>
            <div class="clear"></div>
            <a href="<?php echo U('/space/trade');?>"><div class="tab"><?php echo L('PERSON_TRADE_INFO');?></div></a>
            <div class="clear"></div>
            
            
            <div class="title"><?php echo L('PERSON_TOOLS');?></div>
            <a href="#"><div class="tab"><?php echo L('PERSON_VIRTUAL_STUDIO');?></div></a>
            <div class="clear"></div>
            <a href="#"><div class="tab"><?php echo L('PERSON_REMOTE_RENDERRING');?></div></a>
            <div class="clear"></div>
        </div>
	</div>
    <form method=post>
    <table class="rightbox">
        <tr class="buttons">
        	<td colspan="2">
            	<a href="javascript:void(0);" id="open_ao" onclick="jQuery('#open_ao').hide();jQuery('#close_ao').show();jQuery('.edit').hide();jQuery('.com').show();"><div class="button"><?php echo L('PERSON_EDIT_FOLLOWING');?></div></a>
                <!--<a href="javascript:void(0);" style="display:none;" id="close_ao" onclick="jQuery('#close_ao').hide();jQuery('#open_ao').show();jQuery('.com').hide();jQuery('.edit').show();"><div class="button">COMPLETE</div></a>-->
                <a href="javascript:void(0);" style="display:none;" id="close_ao" onclick="jQuery('form').submit();"><div class="button"><?php echo L('PERSON_COMPLETE');?></div></a>
            </td>
        </tr>
        <tr class="image edit">
       		<td class="title"><?php echo L('PERSON_IMAGE');?> :</td>
        	<td><img src="<?php echo getAvatar($_cUser);?>" class="_avatar"/></td>
        </tr>
        <?php $country = M("country")->getFieldByCode($_cUser["country"],L('COUNTRY_LANG')); ?>
        <tr class="country edit">
        	<td class="title"><?php echo L('PERSON_COUNTRY');?> :</td>
        	<td><?php echo ($country); ?></td>
        </tr>
        <tr class="number edit">
        	<td class="title"><?php echo L('PERSON_TELEPHONE');?> :</td>
        	<td><?php echo h(xserialize($_cUser['contact'],'tel'));?></td>
        </tr>
        <tr class="im edit">
        	<td class="title">IM(QQ&MSN) :</td>
        	<td><?php echo h(xserialize($_cUser['contact'],'im'));?></td>
        </tr>
        <tr class="type edit">
        	<td class="title"><?php echo L('PERSON_TYPES');?> :</td>
        	<td><a href="###"><div class="button"><?php echo $_cUser['usertype']?L(M("cgtype")->getFieldById($_cUser['usertype'],"cgtypename")):"";?></div></a></td>
        </tr>
        <tr class="skill edit">
        	<td class="title"><?php echo L('CONTRACTOR_SKILLS');?> :</td>
        	<td id="skill_view"></td>
        </tr>
        <tr class="about edit">
        	<td class="title"><?php echo L('PERSON_ABOUT');?> :</td>
        	<td><?php echo (h($_cUser["intro"])); ?></td>
        </tr>
        
        <tr class="image com">
       		<td class="title"><?php echo L('PERSON_IMAGE');?> :</td>
        	<td><img src="<?php echo getAvatar($_cUser);?>" class="_avatar" /> <br />
        	<input type="file" name="file_upload" id="file_upload" /></td>
        </tr>
        <tr class="country com">
        	<td class="title"><?php echo L('PERSON_COUNTRY');?> :</td>
        	<td>
            	<div class="box">
                	<div id="countryname" class="country"><?php echo ($country); ?></div>
            		<a id="countrybutton" href="#countrybox"><div class="button"></div></a>
            		<div class="hide">			<div id="countrybox">
            	<div class="firstlist"><a href="#" class="now">A</a><a href="#">B</a><a href="#">C</a><a href="#">D</a><a href="#">E</a><a href="#">F</a><a href="#">G</a><a href="#">H</a><a href="#">I</a><a href="#">J</a><a href="#">K</a><a href="#">L</a><a href="#">M</a><a href="#">N</a><a href="#">O</a><a href="#">P</a><a href="#">Q</a><a href="#">R</a><a href="#">S</a><a href="#">T</a><a href="#">U</a><a href="#">V</a><a href="#">W</a><a href="#">X</a><a href="#">Y</a><a href="#">Z</a></div>
            	<?php echo buildCountry();?><!--
                <div class="countryname" id="ct_A"><div><a href="#">Afghanistan</a></div><div><a href="#">Albania</a></div><div><a href="#">Algeria</a></div><div><a href="#">America</a></div><div><a href="#">Andorra</a></div><div><a href="#">Angola</a></div><div><a href="#" >Antarctica</a></div><div><a href="#">Argentina</a></div><div><a href="#">Armenia</a></div><div><a href="#">Aruba</a></div><div><a href="#">Australia</a></div><div><a href="#">Austria</a></div><div><a href="#">Azerbaijan</a></div></div>-->
                <div class="clear"></div>
                <input type="hidden" name="country" value="" />
            </div>
            <style>
            	#countrybox .countryname { display:none }
            </style>
            <script>
            	$("#countrybox .firstlist a").click(function() {
            		$("#countrybox .firstlist a").removeClass("now");
            		$(this).addClass("now");
            		$("#countrybox .countryname").hide();
            		$("#ct_"+$(this).text()).show();
            	});
            	
            	$(".countryname a").click(function(){
            		$.fancybox.close();
            		var _txt =$(this).text();
            		var _val =$(this).attr("val");
            		$("#countryname").text(_txt);
            		$("#countrybox input[name=country]").val(_val);
            	});
            </script></div>
            		</div></div>
    			</div>
            </td>
        </tr>
        <tr class="number com">
        	<td class="title"><?php echo L('PERSON_TELEPHONE');?> :</td>
        	<td><input type="text" id="tel" name="tel" value="<?php echo h(xserialize($_cUser['contact'],'tel'));?>" onfocus="setStyleOne(this.id)" onblur="setStyleTwo(this.id)"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" /></td>
        </tr>
        <tr class="im com">
        	<td class="title">IM(QQ&MSN) :</td>
        	<td><input type="text" id="im" name="im" value="<?php echo h(xserialize($_cUser['contact'],'im'));?>" onfocus="setStyleOne(this.id)" onblur="setStyleTwo(this.id)"/></td>
        </tr>
        <tr class="type com">
        	<td class="title"><?php echo L('PERSON_TYPES');?> :</td>
        	<td class="typetd">
            <div id="dropDownList1" class="dropDownList dropdown">
  				<select class="hide" name="usertype">
                    <option value="0"><?php echo L('WORK_PLEASE_SELECT');?></option>
   					<?php $cgtype = M("cgtype")->order("`order` asc")->select(); ?>
                    <?php if(is_array($cgtype)): $i = 0; $__LIST__ = $cgtype;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><option value="<?php echo ($data["id"]); ?>" <?php echo (($data['id']==$_cUser['usertype'])?"selected":"");?>><?php echo L($data['cgtypename']);?></option><?php endforeach; endif; else: echo "" ;endif; ?>
  				</select>
  				<span class=""><?php echo ($_cUser['usertype']?L(M("cgtype")->getFieldById($_cUser['usertype'],"cgtypename")):L('WORK_PLEASE_SELECT'));?></span>
            	<ul class="">
            	</ul>
        	</div>
            </td>
        </tr>
        <tr class="skill com">
        	<td class="title"><?php echo L('CONTRACTOR_SKILLS');?> :</td>
        	<td><input type="hidden" name="skill" id="skill_data" value="<?php echo ($_cUser["userskill"]); ?>" /><style>
	#skill_view .button{
		float:left;
		width:auto;
		margin:0px 5px 0px 0px;
	}
	.skillediotr {
		display:none;
	}
	.com .skillediotr {
		display:block;
	}
	.skillediotr .list,.skillediotr .action {
		margin:5px 0px;
	}
	.skillediotr .list .del {
		float:right;
	}
	.skillediotr .action input {
		float:left;
		width:200px;
	}
	.skillediotr .action .button {
		margin:2px 10px;
		float:left;
		width:50px;
		text-align:center
	}
</style>
<div class="skillediotr">
	<div class="list">
		<!--<div class="button"><span>ABC</span> <a href="#" class="del">x</a></div>
		<div class="button"><span>ABC</span> <a href="#" class="del">x</a></div>
		<div class="button"><span>ABC</span> <a href="#" class="del">x</a></div>-->
	</div>
	<div class="action">
		<input type="text" id="new_skill" value="" onfocus="setStyleOne(this.id)" onblur="setStyleTwo(this.id)" />
		<div class="button"><?php echo L('EDITOR_ADD');?></div>
	</div>
</div>

<script>
	$now_skill = $("#skill_data").val().split(',');
	$skill_edit_html = "";
	$skill_html = "";
	for (var si=0;si<$now_skill.length-1;si++) {
		$skill_edit_html += '<div class="button"><span>'+$now_skill[si]+'</span> <a href="javascriot:void(0)" class="del">x</a></div>';
		$skill_html += '<div class="button">'+$now_skill[si]+'</div>';
	}
	$("#skill_view").html($skill_html);
	$(".skillediotr .list").html($skill_edit_html);

	function update_skill(){
		var $new_val = "";
		$(".skillediotr .list .button span").each(function(){
			$new_val += $(this).text()+",";
		});
		$("#skill_data").val($new_val);
		//console.log($new_val);
	}
	$(".skillediotr .list .del").live("click",function() {
		$(this).parent().remove();
		update_skill();
	});
	
	$(".skillediotr .action .button").click(function() {
		$newval = $("#new_skill").val().trim();
		if ($newval) {
			$canadd = true;
			$(".skillediotr .list .button span").each(function(){
				if ($(this).text() == $newval) {
					alert("Duplicate value");
					$canadd = false;
				}
			});
			if ($canadd) {
				$(".skillediotr .list").append('<div class="button"><span>'+$newval+'</span> <a href="javascriot:void(0)" class="del">x</a></div>');
				$("#new_skill").val("");
			}
			update_skill();
		}
	});
	
</script></td>
        </tr>
        <tr class="about com">
        	<td class="title"><?php echo L('PERSON_ABOUT');?> :</td>
        	<td><textarea type="text" id="about" name="intro" onfocus="setStyleOne(this.id)" onblur="setStyleTwo(this.id)"><?php echo (h($_cUser["intro"])); ?></textarea></td>
        </tr>
    </table>
    <input type="hidden" name="_submit" value="1"/>
    </form>
</div>

<div class="footer">

</div>
<?php echo importJS("downlist.js");?>
<script type="text/javascript" src="__ROOT__/themes/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
</body>
</html>